﻿@model PagedList<Background.Core.Entity.WebManageMenus>
@{
    ViewBag.Title = "Index";
}
<table>
    <tr>
        <th>
        </th>
        <th>
            编号
        </th>
        <th>
            名称
        </th>
        <th>
            父ID
        </th>
        <th>
            菜单级别
        </th>
        <th>
            菜单Url
        </th>
        <th>
            排序
        </th>
        <th>
            状态
        </th>
    </tr>
    @if (Model != null && Model.Count > 0)
    {
        <tbody>
            @foreach (var item in Model)
            {
                <tr>
                    <td>
                        @Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
                        @Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
                        @Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
                    </td>
                    <td>
                        @item.MenuID
                    </td>
                    <td>
                        @item.MenuName
                    </td>
                    <td>
                        @item.ParentID
                    </td>
                    <td>
                        @item.MenuLevel
                    </td>
                    <td>
                        @item.LinkUrl
                    </td>
                    <td>
                        @item.SortNumber
                    </td>
                    <td>
                        @item.Status
                    </td>
                </tr>
            }
        </tbody>
        <tfoot>
            <tr>
                <td colspan="8">@Html.Pager(Model)
                </td>
            </tr>
        </tfoot>
    }
</table>
<link href="../../Scripts/JQTree/themes/checkbox/style.css" rel="stylesheet" type="text/css" />
<link href="../../Scripts/JQTree/themes/default/style.css" rel="stylesheet" type="text/css" />
<script src="../../Scripts/JQTree/jquery.tree.js" type="text/javascript"></script>
<script src="../../Scripts/JQTree/plugins/jquery.tree.checkbox.js" type="text/javascript"></script>
<script type="text/javascript">
    var modal = new Object();
    $(document).ready(function () {
        $("#PageTree").tree({ "plugins": ["themes", "html_data", "ui"] });
        return;
        $(".EditWebManageMenus,.AddWebManageMenus").live("click", function () {
            var option = { sender: this, url: this.href };
            modal.dialog("open");
            modal.load(option.url, function (e) {
                var frm = $(modal).find("form");
                frm.validate({
                    errorPlacement: function (error, element) {
                        if (element.next(".field-validation-error").length == 0)
                            error.attr({ className: "field-validation-error" }).insertAfter(element);
                        else
                            error.attr({ className: "field-validation-error" }).replaceAll(element.next(".field-validation-error"))
                    },
                    success: function (label) {
                    },
                    rules: {
                        MenuName: {
                            required: true,
                            minlength: 2,
                            maxlength: 100
                        },
                        LinkUrl: {
                            minlength: 2,
                            maxlength: 300
                        },
                        About: {
                            required: true,
                            minlength: 2,
                            maxlength: 100
                        }
                    },
                    submitHandler: function (form) {
                        $(frm).ajaxSubmit({ dataType: "json", error: function () { modal.dialog("close") }, success: function (e) {
                            if (e == true) {
                                $("#PageTree").load(window.location.href, function () { modal.dialog("close") });
                            }
                        }
                        });
                    }
                });
            });
            return false;
        });
        $(".DeleteWebManageMenus").live("click", function () {
            var option = { sender: this, url: this.href };
            confirm(function () {
                $.ajax({
                    url: option.url,
                    dataType: "json",
                    success: function (e) {
                        $("#PageTree").load(window.location.href)
                    },
                    error: function (e, t, x) {
                        $("#PageTree").load(window.location.href)
                    }
                });
            });

        });
        modal = $("#Modal").dialog({ modal: true, title: "菜单数据", autoOpen: false });

    });
</script>
@Html.Action("PartialWebWebManageMenusTree", "WebManageMenus")
